<?php
	include "../common.php";	
	$json = file_get_contents('php://input');
	
	$post = json_decode($json);
	
	$movieId = $post->{'movie_id'};
	$pageIndex = $post->{'page_index'};
	$pageCounts = $post->{'page_counts'};
	
	$conn = linkMySql();
	
	$sql = "SELECT ". USER_TABLE.".".USER_NAME. " , "
			. USER_TABLE.".".USER_HEADER.","
			. MIDDLE_NEWEST_MOVIE.".".NEWEST_MOVIE_COMMON." AS common , "
			. MIDDLE_NEWEST_MOVIE.".".NEWEST_MOVIE_COMMON_TIME." AS common_time"
		    . " FROM ".USER_TABLE." , ".MIDDLE_NEWEST_MOVIE.",".NEWEST_MOVIE
            . " WHERE ". MIDDLE_NEWEST_MOVIE.".".PRAISE_OR_SCAN." = 1 AND "
            . MIDDLE_NEWEST_MOVIE.".".MIDDLE_MOVIE_ID ." = "
            . NEWEST_MOVIE.".".MOVIE_ID." AND ".NEWEST_MOVIE.".".MOVIE_ID ."= $movieId"
            . " AND ". MIDDLE_NEWEST_MOVIE.".".MIDDLE_USER_ID." = ". USER_TABLE.".".USER_ID;
	
	$result = mysqli_query($conn, $sql);
	
	while($array = mysqli_fetch_assoc($result)) {
		$commons[] = $array;
	}
	$encode = array("tag"=> MOVIE_DETAILS_COMMONS, "movie_commons" => $commons);
	
	echo json_encode($encode);die;
?>